﻿@using Microsoft.AspNet.Identity
@{ 
    if(Request.Cookies["Basket_id"]!=null)
    {
        string bi = Request.Cookies["Basket_id"].Value;
        ViewBag.Id = Int32.Parse(bi);
    }
    else
    {
        ViewBag.Id = 1;
    }
}
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
    {
    @Html.AntiForgeryToken()

    <ul class="nav navbar-nav navbar-right">
        <li>
            @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
        </li>
        @if (!User.IsInRole("Admin"))
        {
            <li>@Html.ActionLink("Basket", "Index", "Basket", new { id = ViewBag.Id }, false)</li>
        }
        <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
    </ul>
    }
}
else
{
    <ul class="nav navbar-nav navbar-right">
        <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
        <li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
    </ul>
}
